home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / d3_light.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  6.1 KB  |  183 lines

  1. /*****************************************************************************
  2.   FILE           : d3_light.c
  3.   SHORTNAME      : light.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : controls the light pannel
  7.   NOTES          : 1.12.1991
  8.  
  9.   AUTHOR         : Ralf Huebner
  10.   DATE           : 1.12.1991
  11.  
  12.   CHANGED BY     : Sven Doering
  13.   IDENTIFICATION : @(#)d3_light.c    1.9 3/2/94
  14.   SCCS VERSION   : 1.9
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #include <stdio.h>
  21. #include <memory.h>
  22.  
  23. #include <X11/Xlib.h>
  24. #include <X11/Xutil.h>
  25. #include <X11/Intrinsic.h>
  26. #include <X11/StringDefs.h>
  27. #include <X11/Shell.h>
  28. #include <X11/Xaw/Simple.h>
  29. #include <X11/Xaw/Box.h>
  30. #include <X11/Xaw/Form.h>
  31. #include <X11/Xaw/Toggle.h>
  32. #include "glob_typ.h"
  33. #include "ui.h"
  34. #include "ui_xWidgets.h"
  35. #include "d3_global.h"
  36. #include "d3_xUtils.h"
  37. #include "d3_main.h"
  38.  
  39. #include "d3_light.ph"
  40.  
  41. /*****************************************************************************
  42.   FUNCTION : d3_closeLightPannel 
  43.  
  44.   PURPOSE  : close the project pannel
  45.   RETURNS  : 
  46.   NOTES    :
  47.  
  48. ******************************************************************************/
  49.  
  50.  
  51. static void d3_closeLightPannel (Widget w, Widget pannel, caddr_t call_data)
  52. {
  53.     temp_state.light.position[0] = ui_xFloatFromAsciiWidget (lightXwidget);
  54.     temp_state.light.position[1] = ui_xFloatFromAsciiWidget (lightYwidget);
  55.     temp_state.light.position[2] = ui_xFloatFromAsciiWidget (lightZwidget);
  56.  
  57.     temp_state.light.Ia = ui_xFloatFromAsciiWidget (lightIaWidget);
  58.     temp_state.light.Ka = ui_xFloatFromAsciiWidget (lightKaWidget);
  59.  
  60.     temp_state.light.Ip = ui_xFloatFromAsciiWidget (lightIpWidget);
  61.     temp_state.light.Kd = ui_xFloatFromAsciiWidget (lightKdWidget);
  62.     XtDestroyWidget (pannel);
  63.     if (memcmp (&d3_state, &temp_state, 
  64.                 sizeof (d3_state_type)) != 0) {
  65.          memcpy (&d3_state, &temp_state, 
  66.                  sizeof (d3_state_type)); 
  67.          d3_drawNet ();
  68.     }
  69.  
  70. }
  71.  
  72.  
  73.  
  74.  
  75. /*****************************************************************************
  76.   FUNCTION : d3_createLightPannel
  77.  
  78.   PURPOSE  : creates the light pannel
  79.   RETURNS  : 
  80.   NOTES    :
  81.  
  82. ******************************************************************************/
  83.  
  84.  
  85.  
  86.  
  87. void d3_createLightPannel (Widget w, Widget button, caddr_t call_data)
  88. {
  89.     int n;
  90.     Arg arg[10];
  91.     char buf[20];
  92.     Position xPos, yPos;
  93.     Dimension width, height;
  94.     Widget lightPannel, border, pannel, labelX, labelY, labelZ, done;
  95.     Widget labelA, labelI, labelR;
  96.  
  97.     n = 0;
  98.     XtSetArg (arg[n], XtNwidth, &width); n++;
  99.     XtSetArg (arg[n], XtNheight, &height); n++;
  100.     XtGetValues (button, arg, (unsigned int) n);
  101.  
  102.     XtTranslateCoords (button, (Position) (width / 2), (Position) (height / 2), 
  103.                        &xPos, &yPos);
  104.  
  105.  
  106.     n = 0;
  107.  
  108.     XtSetArg(arg[n], XtNx, xPos); n++;
  109.     XtSetArg(arg[n], XtNy, yPos); n++;
  110.  
  111.     lightPannel = XtCreatePopupShell ("light", transientShellWidgetClass, 
  112.                                       button, arg, (unsigned int) n);
  113.  
  114.     border = XtCreateManagedWidget("border", boxWidgetClass, 
  115.                                    lightPannel, NULL, ZERO);
  116.     pannel = XtCreateManagedWidget("pannel", formWidgetClass, border, NULL, ZERO);
  117.  
  118.     labelX = ui_xCreateLabelItem ("  Light Source  X", pannel, d3_fontWidth * 17, 
  119.                                   NULL, NULL); 
  120.  
  121.     sprintf (buf, "%.4f", d3_state.light.position[0]);
  122.     lightXwidget = ui_xCreateDialogItem ("lightX", pannel, buf, d3_numberWidth,                                          labelX, NULL);
  123.     labelY = ui_xCreateLabelItem ("                Y", pannel, d3_fontWidth * 17, 
  124.                                   NULL, labelX); 
  125.  
  126.     sprintf (buf, "%.4f", d3_state.light.position[1]);
  127.     lightYwidget = ui_xCreateDialogItem ("lightY", pannel, buf, d3_numberWidth, 
  128.                                          labelY, labelX);
  129.  
  130.     labelZ = ui_xCreateLabelItem ("                Z", pannel, d3_fontWidth * 17, 
  131.                                   NULL, labelY); 
  132.  
  133.     sprintf (buf, "%.4f", d3_state.light.position[2]);
  134.     lightZwidget = ui_xCreateDialogItem ("lightZ", pannel, buf, d3_numberWidth, 
  135.                                          labelZ, labelY);
  136.  
  137.  
  138.     labelA = ui_xCreateLabelItem ("  Ambient Light", pannel, d3_fontWidth * 14,
  139.                                   NULL, labelZ);
  140.  
  141.     labelI = ui_xCreateLabelItem ("      Intensity", pannel, d3_fontWidth * 15,
  142.                                   NULL, labelA);
  143.     sprintf (buf, "%.4f", d3_state.light.Ia);
  144.     lightIaWidget = ui_xCreateDialogItem ("lightIa", pannel, buf, d3_numberWidth, 
  145.                                           labelI, labelA);  
  146.  
  147.     labelR = ui_xCreateLabelItem ("     Reflection", pannel, d3_fontWidth * 15, 
  148.                                   NULL, labelI);
  149.     sprintf (buf, "%.4f", d3_state.light.Ka);
  150.     lightKaWidget = ui_xCreateDialogItem ("lightKa", pannel, buf, d3_numberWidth, 
  151.                                           labelR, labelI);  
  152.  
  153.     labelA = ui_xCreateLabelItem ("  Diffuse Light", pannel, d3_fontWidth * 14, 
  154.                                   NULL, labelR);
  155.  
  156.     labelI = ui_xCreateLabelItem ("      Intensity", pannel, d3_fontWidth * 15, 
  157.                                   NULL, labelA);
  158.     sprintf (buf, "%.4f", d3_state.light.Ip);
  159.     lightIpWidget = ui_xCreateDialogItem ("lightIp", pannel, buf, d3_numberWidth,
  160.                                           labelI, labelA);  
  161.  
  162.     labelR = ui_xCreateLabelItem ("     Reflection", pannel, d3_fontWidth * 15,
  163.                                   NULL, labelI);
  164.     sprintf (buf, "%.4f", d3_state.light.Kd);
  165.     lightKdWidget = ui_xCreateDialogItem ("lightKd", pannel, buf, d3_numberWidth,
  166.                                            labelR, labelI);  
  167.  
  168.     done = d3_xCreateButtonItem ("done", border, NULL, lightIaWidget);
  169.  
  170.     XtAddCallback (done, XtNcallback, (XtCallbackProc) d3_closeLightPannel, (Widget) lightPannel);
  171.  
  172.     memcpy (&temp_state, &d3_state, sizeof (d3_state_type)); 
  173.  
  174.  
  175.     ui_checkWindowPosition(lightPannel);
  176.     XtPopup (lightPannel, XtGrabExclusive);
  177.  
  178. }
  179.  
  180.  
  181. /* end of file */
  182. /* lines: 200 */
  183.